<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function name(){
            return new Promise((resolve,reject)=>{
                try{
                    setTimeout(() => {
                        console.log('得到姓名有关数据');
                        const name  = {
                        name: '张三'
                    }
                    resolve(
                        name
                    )
                    }, 1500);
                  
                }catch(e){
                    reject(e.massage)
                }
            })
        }
        function age(names){
            return new Promise((resolve,reject)=>{
                try{
                    setTimeout(() => {
                        console.log('得到年龄有关数据');
                        const age = { 
                        age: 18 
                    }
                    resolve(
                        {
                            ...names,
                            ...age
                        }
                    )
                    }, 1500);
                  
                }catch(e){
                    reject(e.massage)
                }
            })
        }
        function sex(ages){
            return new Promise((resolve,reject)=>{
                try{
                    setTimeout(() => {
                        console.log('得到性别有关数据');
                        const sex = {
                        sex:'男'
                    }
                    resolve(
                        {
                           ...ages,
                           ...sex
                        }
                    )
                    }, 1500);
                 
                }catch(e){
                    reject(e.massage)
                }
            })
        }
        async  function  fn(){
            const names =await name() 
            // console.log(names);  
            const ages =await age(names)
            // console.log(ages);
            const sexs =await sex(ages) 
            console.log('得到全部数据是',sexs);
        }
        fn()
    </script>
</body>
</html>